-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix callback compatibility for trainable_model #878
Fix callback compatibility for trainable_model #878
Conversation
I guess I am trying to understand the relationship of this callback to that of the optimizers. Yes it looks to be the same signature as a scipy optimizer one but otherwise this is just a callback, True if you are using SPSA and have a callback for that, since it has a different signature you could not use it for the callback here in this context. The test which is failing is using SPSA, which presumably worked before, so I am having a hard time figuring things. |
Maybe, changing optimizers such as SPSA and ADAM might be a better option |
releasenotes/notes/fix-callback-trainable_model-ca52060260a3e466.yaml
Outdated
Show resolved
Hide resolved
I guess I am still confused to some degree. The trainable model has its own callback that it defines right - it may have the same signature as scipy optimizer one but that is the only correlation as far as I know. The test was working with SPSA, which itself has a different callback. The issue really did not provide enough information for me to understand besides the notion that something mismatched - no code sample to reproduce or whatever. |
Hi Steve, I was not clear enough on the issue, maybe this might be useful: SPSA has its own callback function since it is not based on qiskit-machine-learning/qiskit_machine_learning/optimizers/spsa.py Lines 580 to 588 in 94ccb0a
But trainable_model makes calls itself, and I think it is only compatible with qiskit-machine-learning/qiskit_machine_learning/algorithms/trainable_model.py Lines 270 to 273 in 94ccb0a
and my suggested change is:
This way we can allow custom callback functions and clear potential ambiguity when the function is called (inside or outside of the optimisation loop for custom callback functions). Please note that SPSA is used in tutorials with QKT, not with trainable models:
I think trainable models must be adaptive if |
…66.yaml Co-authored-by: Edoardo Altamura <[email protected]>
Pull Request Test Coverage Report for Build 12356721976Details
💛 - Coveralls |
* Fix callback compatibility for trainable_model * Update releasenotes/notes/fix-callback-trainable_model-ca52060260a3e466.yaml Co-authored-by: Edoardo Altamura <[email protected]> * Update tests with callbacks * Disable pylint unused arguments in tests --------- Co-authored-by: Edoardo Altamura <[email protected]> (cherry picked from commit 02ee6a7)
* Fix callback compatibility for trainable_model * Update releasenotes/notes/fix-callback-trainable_model-ca52060260a3e466.yaml Co-authored-by: Edoardo Altamura <[email protected]> * Update tests with callbacks * Disable pylint unused arguments in tests --------- Co-authored-by: Edoardo Altamura <[email protected]> (cherry picked from commit 02ee6a7) Co-authored-by: M. Emre Sahin <[email protected]>
Summary
Fixed a compatibility issue as mentioned in #877 for different
callback
functions when it is used in trainable_model based algorithms.Fixes #877